#pragma onece
#include "systemc.h"
// Control for the FSM

#define CYCLK 1
SC_MODULE(SM3_Controller)
{

	sc_in<bool> clk , rst , W , R ;

	sc_out<bool> finish ;
	sc_out<sc_int<7> > count_out ;
	sc_out<sc_int<2> > ctrl ;

	sc_signal<sc_int<7> >  count_out , count ;
	sc_signal<sc_int<2> >  next_state , current_state;
	sc_signal<sc_int<7> >  count_plus ;

#define idle 0b00
#define write 0b01
#define encryption 0b10
#define read 0b11

	void assign_count_plus();
	void assign_ctrl();

	void always_block1();
	void always_block2();//              default
//                    next_state <= idle ;
//output logic
// at each state , we can output signals

	void always_block3();
	SC_CTOR(SM3_Controller)
	{
		SC_METHOD(assigncount_plus);
		sensitive < <count;
		SC_METHOD(assignctrl);
		sensitive < <next_state;

		SC_METHOD(always_block1);
		sensitive< <clk.pos()< <rst.neg();
		SC_METHOD(always_block2);
		sensitive< <clk.pos()< <rst.neg();
		SC_METHOD(always_block3);
		sensitive< <clk.pos()< <rst.neg();
	}
};